From 5331e04f4d90daa69ee5376e7b991fa48399c204 Mon Sep 17 00:00:00 2001 From: oliskoli Date: Thu, 30 Nov 2006 01:32:41 +0000 Subject: [PATCH] Do not read empty files. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@2559 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/mapsend.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gpsbabel/mapsend.c b/gpsbabel/mapsend.c index 90cb6aa63..89629d1ba 100644 --- a/gpsbabel/mapsend.c +++ b/gpsbabel/mapsend.c @@ -313,7 +313,7 @@ static void mapsend_read(void) { mapsend_hdr hdr; - int type; + int type, len; char buf[3]; /* @@ -321,7 +321,9 @@ mapsend_read(void) * strings, each member has to be read in one at a time. Grrr. */ - fread(&hdr, sizeof(hdr), 1, mapsend_file_in); + len = fread(&hdr, 1, sizeof(hdr), mapsend_file_in); + is_fatal(len < sizeof(hdr), MYNAME ": No mapsend or empty file!"); + type = le_read16(&hdr.ms_type); strncpy(buf, hdr.ms_version, 2); buf[2] = '\0'; -- 2.30.2